package com.theten52.demo.run;

import com.theten52.demo.load.util.LoadLibraryUtil;
import com.theten52.demo.load.library.NativeDemo2;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 本地方法库加载组件
 *
 * @author wangjin
 * @date 2021/6/2
 */
@Component
public class LoadLibraryComponent implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {

        LoadLibraryUtil.loadLibrary("NativeDemo2");
        LoadLibraryUtil.loadLibrary("NativeDemo");

        NativeDemo2 nativeDemo = new NativeDemo2();
        System.out.println("NativeDemo ClassLoader:" + nativeDemo.getClass().getClassLoader());
        int add = nativeDemo.add(1, 2);
        System.out.println("===add result:" + add);
        System.out.println("-------");
    }
}
